package stu.day19_day24.day22;

import java.util.Arrays;
import java.util.Scanner;

public class hw3 {

    public static int cal_time(int n,int m,int[] arr){
        int allTime = 0;
        int cap = m;
        int i = 0;
        while (i<arr.length){
            if(cap>=arr[i]){
                cap -= arr[i];
                cap += n;
                allTime +=1;
                i += 1;
            }else {
                cap += n;
                allTime += 1;
            }
        }
        return allTime;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int m = Integer.parseInt(sc.nextLine());
        int[] arr = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int left = 1;
        int right = Arrays.stream(arr).max().getAsInt()+1;

        while (left<right){
            int mid = (left+right)/2;
            int days = cal_time(mid,m,arr);
            System.out.println(mid+" "+days);

            if(days<=n){
             right =  mid;
            }else {
               left = mid+1;
            }

        }

        System.out.println(left);

    }

}
